#include<iostream>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int, int> pi;
const int maxn = 1e4+7;
int N, L, P;
pi stop[maxn];
// int A[maxn], B[maxn];
void solve() {
  stop[N] = {L, 0}; N++;
  priority_queue<int> pq;
  int pos = 0, ans = 0, tank = P;
  for(int i=0; i<N; ++i) {
    int d = stop[i].first - pos;
    while(tank-d<0) {
      if(pq.empty()) {
        cout<<"-1\n";
        return;
      }
      tank += pq.top();pq.pop(); ans++;
    }
    tank -= d;
    pq.push(stop[i].second);
    pos = stop[i].first;
  }
  cout<<ans<<'\n';
  return;
}
int main() {
  cin>>N;
  for(int i=0; i<N; ++i) {
    cin>>stop[i].first>>stop[i].second;
  }
  sort(stop, stop+N, [](pi a, pi b) {
    return a.first<b.first;
  });
  cin>>L>>P;
  solve();
  return 0;
}